<template>
  <div class="sm-st-topSearch">
    <ul>
      <li>
        机型
        <el-input
            ref="saomaInput"
            size="mini"
            v-model="searchData.productCode"
            placeholder="请输入内容"
          ></el-input>
      </li>
      <li class="sm-st-choiceli">
        批次
        <el-input
            ref="saomaInput"
            size="mini"
            v-model="searchData.batchNo"
            placeholder="请输入内容"
          ></el-input>
      </li>
      <li class="sm-st-choiceli">
        起始架次
        <el-input
            ref="saomaInput"
            size="mini"
            v-model="searchData.startPlaneNo"
            placeholder="请输入内容"
          ></el-input>
      </li>
      <li>
        开始时间
        <el-date-picker
            size="mini"
            v-model="searchData.startTime"
            type="date"
            placeholder="选择日期"
            value-format="yyyy-MM-dd"
          ></el-date-picker>
      </li>
      <li>
        结束时间
        <el-date-picker
            size="mini"
            v-model="searchData.endTime"
            type="date"
            placeholder="选择日期"
            value-format="yyyy-MM-dd"
          ></el-date-picker>
      </li>
      <li class="sm-st-choiceli">
        <el-button size="mini" type="primary" @click="smstSearch">查询</el-button>
      </li>
    </ul>
  </div>
</template>
<script>
import { smSpmTopTableSearch } from "@/utils/api.js"
export default {
  name: "topSearch",
  data() {
    return {
      searchData:{
        productCode:'',
        batchNo:'',
        startPlaneNo:'',
        startTime:'',
        endTime:''
      },
      pageSize:20,
      pageNumber:1
    };
  },
  methods:{
    // 查询
    smstSearch(){
      smSpmTopTableSearch({
        searchParams:{
          productCode:this.searchData.productCode,
          batchNo:this.searchData.batchNo,
          startPlaneNo:this.searchData.startPlaneNo
        },
        startTime:this.searchData.startTime,
        endTime:this.searchData.endTime,
        pageParameter:{
          rows:this.pageSize,
          page:this.pageNumber
        }
      }).then((res)=>{
        if(res.data.retCode == 200){
          this.$bus.$emit('smStTopSearch',res)
        }
        console.log('配套任务上表查询',res)
      })
    }
  },
  mounted(){
    // 接收Top表的分页--每页条数--进行查询
    this.$bus.$on('smStToptablePageSize',(e)=>{
      this.pageSize = e
      smSpmTopTableSearch({
        searchParams:{
          productCode:this.searchData.productCode,
          batchNo:this.searchData.batchNo,
          startPlaneNo:this.searchData.startPlaneNo
        },
        startTime:this.searchData.startTime,
        endTime:this.searchData.endTime,
        pageParameter:{
          rows:this.pageSize,
          page:this.pageNumber
        }
      }).then((res)=>{
        if(res.data.retCode == 200){
          this.$bus.$emit('smStTopSearch',res)
        }
        console.log('配套任务上表查询',res)
      })
    })
    // 接收Top表的分页--页数--进行查询
    this.$bus.$on('smStToptablePageNumber',(e)=>{
      this.pageNumber = e
      smSpmTopTableSearch({
        searchParams:{
          productCode:this.searchData.productCode,
          batchNo:this.searchData.batchNo,
          startPlaneNo:this.searchData.startPlaneNo
        },
        startTime:this.searchData.startTime,
        endTime:this.searchData.endTime,
        pageParameter:{
          rows:this.pageSize,
          page:this.pageNumber
        }
      }).then((res)=>{
        if(res.data.retCode == 200){
          this.$bus.$emit('smStTopSearch',res)
        }
        console.log('配套任务上表查询',res)
      })
    })
  }
};
</script>
<style scoped>
.sm-st-topSearch {
  padding: 5px 3px;
  width: 100%;
  height: 100%;
  margin-top: 10px;
  overflow: hidden;
}
.sm-st-topSearch ul li {
    float: left;
    margin-left: 5px;
}
.sm-st-choiceli {
    margin-left: 10px;
}
.el-select {
    width: 120px;
}
.el-input {
  width: 150px;
}
</style>